package MobileMWClient;

import java.util.LinkedList;
import java.util.Queue;

/**
 * <pre>
 * @Package : MWClient
 * @File    : SerialQueue.java
 * <pre>
 *
 * @Author  : 차재우
 * @Date    : 2013. 7. 22.
 * @Version :
 */
public class SerialQueue {
	private Queue<PassData> q = new LinkedList<PassData>();

	/**
	 * <pre>
	 * @Comment : 생성자
	 * <pre>
	 *
	 */
	public SerialQueue() {
		
	}
	
	/**
	 * <pre>
	 * @Comment : 큐가 비어있는지 확인
	 * <pre>
	 *
	 * @Method  : IsEmpty
	 * @return
	 */
	public boolean IsEmpty() {
		return q.isEmpty();
	}

	/**
	 * <pre>
	 * @Comment : 데이터 push
	 * <pre>
	 *
	 * @Method  : Push
	 * @param input
	 * @return
	 */
	public synchronized boolean Push(byte[] input) {			
		PassData data = new PassData();
		data.setCardData(input);

		// 큐에 저장
		boolean ret = q.offer(data);

		return ret;
	}
	
	/**
	 * <pre>
	 * @Comment : 데이터 pop
	 * <pre>
	 *
	 * @Method  : Pop
	 * @return
	 */
	public synchronized PassData Pop() {
		return (PassData)q.poll();
	}
	
	
	/**
	 * <pre>
	 * @Comment : 큐 사이즈
	 * <pre>
	 *
	 * @Method  : GetQueueSize
	 * @return
	 */
	public int GetQueueSize() {
		return q.size();
	}
}
